package com.zmj.sy.mom.srv.aps.controller;


import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseListResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.base.BaseResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.groupworkrule.GroupWorkRuleFindShiftReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.groupworkrule.GroupWorkRuleFindShiftResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.groupworkrule.GroupWorkRuleTimeRangeReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.groupworkrule.GroupWorkRuleTimeRangeResVo;
import com.zmj.sy.mom.srv.aps.bean.vo.shifttyperule.ShiftTeamRuleAddReqVo;
import com.zmj.sy.mom.srv.aps.bean.vo.shifttyperule.ShiftTeamRuleRemoveReqVo;
import com.zmj.sy.mom.srv.aps.service.GroupWorkRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequiredArgsConstructor
@Api(tags = "工作组能力管理")
@RestController
@RequestMapping("/groupWorkRule")
public class GroupWorkRuleController {

    private final GroupWorkRuleService groupWorkRuleService;

    @ApiOperation("添加班组规则")
    @PostMapping("/add")
    public BaseResVo add(@RequestBody ShiftTeamRuleAddReqVo reqVo) {
        groupWorkRuleService.add(reqVo);
        return BaseResVo.ok("添加成功");
    }

    @ApiOperation("删除班组规则")
    @PostMapping("/remove")
    public BaseResVo remove(@RequestBody ShiftTeamRuleRemoveReqVo reqVo) {
        groupWorkRuleService.remove(reqVo);
        return BaseResVo.ok("删除成功");
    }

    @ApiOperation("获取工作组班次")
    @GetMapping("/findShift")
    public BaseListResVo<GroupWorkRuleFindShiftResVo> findShift(GroupWorkRuleFindShiftReqVo reqVo) {
        List<GroupWorkRuleFindShiftResVo> shiftTeamRuleAddReqVos = groupWorkRuleService.findShift(reqVo);
        return BaseListResVo.of(shiftTeamRuleAddReqVos, GroupWorkRuleFindShiftResVo.class);
    }

    @ApiOperation("1.5.5 获取班组日历")
    @GetMapping("/timeRange")
    public BaseListResVo<GroupWorkRuleTimeRangeResVo> timeRange(GroupWorkRuleTimeRangeReqVo reqVo) {
        List<GroupWorkRuleTimeRangeResVo> resVoList = groupWorkRuleService.timeRange(reqVo);
        return BaseListResVo.of(resVoList, GroupWorkRuleTimeRangeResVo.class);
    }

}
